/**
 * @author SilverBiology, LLC
 * @website http://code.google.com/p/gbif-spreadsheet-processor/
*/
Ext.namespace('GBIF');
Ext.namespace('GBIF.GeoSpatial')

GBIF.GeoSpatial.KML = function(config){
	
	Ext.apply(this,config,{
			height: 400
		,	border: false
		,	zoom: 2
		,	tbar: [{
					xtype:'label'
				,	style:"padding:0px 5px"	
				,	text:'Enter KML feed:'	
			}, {
					xtype: 'textfield'  
				,	width: 350
				,	ref: '../url'
				,	name: 'urlLoad'
			}, {
					text: 'Load'
				,	style:"padding:0px 5px"
				, scope: this
				,	handler: this.loadKML
			}]
		,	proxyUrl: Config.General.Home.url + "api/getcapabilities-proxy.php?url="
	});                     
		
	GBIF.GeoSpatial.KML.superclass.constructor.call(this, config)
}

Ext.extend(GBIF.GeoSpatial.KML,GBIF.GeoSpatial.MapComponent, {
	
	loadKML: function(){
		var urlValue = this.proxyUrl+this.url.getValue();
		var layerKML = new OpenLayers.Layer.GeoRSS("Fire",urlValue);
		
		if(urlValue==''){
			GBIF.GeoSpatial.Notice.msg("Error","Please enter KML URL");
		} else {
			this.map.addLayer(layerKML);
		}
	}
})

